#include "StdAfx.h"
#include "BuildPoint.h"
#include "Field.h"

namespace catan
{
	BuildPoint::BuildPoint(void)
	{
	}
	
	BuildPoint::~BuildPoint(void)
	{
	}

	void BuildPoint::AddField( Handle<Field> field )
	{
		BuildPointDirection::Enum direction = BuildPointDirection::Enum(0);
		for (; (int)direction < (int)field->mBuildPoints.size(); ++(int&)direction )
		{
			if (field->mBuildPoints[direction].Get() == this)
			{
				break;
			}
		}
		//BuildPointDirection::Enum direction = BuildPointDirection::Enum (std::find(field->mBuildPoints.begin(), field->mBuildPoints.end(), this) - field->mBuildPoints.begin());
		if(mFields.find(direction) == mFields.end())
		{
			mFields[direction] = field;
		}

		assert(mFields.size() <= 3 && mFields.size() != 0);

	}

	void BuildPoint::AddEdge(Handle<Edge> edge )
	{
		if(std::find(mEdges.begin(), mEdges.end(), edge) == mEdges.end())
		{
			mEdges.push_back(edge);
		}
		assert(mEdges.size() <= 3);
	}
}	